//
//  CCForumHotTalkViewCell.m
//  CwinCar
//
//  Created by dlios on 15/10/19.
//  Copyright © 2015年 dlios. All rights reserved.
//

#import "CCForumHotTalkViewCell.h"

@implementation CCForumHotTalkViewCell

/*
 // Only override drawRect: if you perform custom drawing.
 // An empty implementation adversely affects performance during animation.
 - (void)drawRect:(CGRect)rect {
 // Drawing code
 }
 */
- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self)
    {
        self.postTitleLabel = [[UILabel alloc]initWithFrame:CGRectMake(mainScreen_Width / 37.5, 7, mainScreen_Width / 1.056, mainScree_Height / 33.35)];
        [self.contentView addSubview:self.postTitleLabel];
        
        self.viewCountLabel = [[UILabel alloc]initWithFrame:CGRectMake(mainScreen_Width / 1.25, mainScree_Height / 15.511,mainScreen_Width / 6.25, mainScree_Height / 33.35)];
        self.viewCountLabel.font = [UIFont systemFontOfSize:14.];
        [self.viewCountLabel setTextColor:[UIColor grayColor]];
        [self.contentView addSubview:self.viewCountLabel];
        
        self.forumNameLabel = [[UILabel alloc]initWithFrame:CGRectMake(mainScreen_Width / 1.923, mainScree_Height/ 15.511, mainScreen_Width/ 4.6875, mainScree_Height / 33.35)];
        self.forumNameLabel.font = [UIFont systemFontOfSize:14.];
        [self.forumNameLabel setTextColor:[UIColor lightGrayColor]];
        [self.contentView addSubview:self.forumNameLabel];
        
        self.replyDateLab = [[UILabel alloc]initWithFrame:CGRectMake(mainScreen_Width / 37.5, mainScree_Height / 15.511, mainScreen_Width / 2.5, mainScree_Height / 33.35)];
        [self.replyDateLab setTextColor:[UIColor grayColor]];
        [self.contentView addSubview:self.replyDateLab];
        
        self.clickImageView = [[UIImageView alloc]initWithFrame:CGRectMake(mainScreen_Width / 1.388, mainScree_Height / 15.511, mainScreen_Width / 18.75, mainScree_Height / 33.35)];
        [self.clickImageView setImage:[UIImage imageNamed:@"dianji_black"]];
        [self.contentView addSubview:self.clickImageView];
        
        self.picView = [[UIImageView alloc]initWithFrame:CGRectMake(mainScreen_Width / 2.272, mainScree_Height / 15.511,mainScreen_Width / 18.75, mainScree_Height / 33.35)];
        
        [self.contentView addSubview:self.picView];
        
    }
    return self;
}
- (void)setData:(CCForumHotModel *)hotModel
{
    NSString *temp = [NSString stringWithFormat:@"%@",hotModel.hasImage];
    if ([temp isEqual:@"1"]) {
        self.isType = YES;
        [self.picView setImage:[UIImage imageNamed:@"biaoqing_tupan"]];
    }else
    {
        self.isType = NO;
    }
    [self.postTitleLabel setText:hotModel.postTitle];
    self.viewCountLabel.text = [NSString stringWithFormat:@"%@",hotModel.viewCount];
    self.forumNameLabel.text = hotModel.forumName;
    int time = hotModel.replyDate.intValue;
    NSDate *date = [NSDate dateWithTimeIntervalSince1970:time];
    NSDateFormatter *formatter = [[NSDateFormatter alloc]init];
    [formatter setDateFormat:@"yyyy-MM-dd HH:mm"];
    NSString *tempDate = [formatter stringFromDate:date];
    self.replyDateLab.font = [UIFont systemFontOfSize:14.];
    self.replyDateLab.text = tempDate;
}
@end
